#include<bits/stdc++.h>
//fangweibiaoqian
#define int long long
using namespace std;
const int N=1e5+5;
int t,n,m,sum,ans,l=1,x[N],p1[N];
int L,V,p[N];
struct node{
	int d,v,a,v1[N];
}c[N];
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    cin>>t;
    while(t--){
		sum=0;ans=0;m=1;
		cin>>n>>m>>L>>V;
		for(int i=1;i<=n;i++){
			cin>>c[i].d>>c[i].v>>c[i].a;
			if(c[i].v>V&&c[i].a==0)sum++;
		}
		for(int i=1;i<=m;i++){
			cin>>p[i];
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(p[j]>=c[i].d)
					if((c[i].v*c[i].v+2*c[i].a*(p[j]-c[i].d))>V*V){ sum++;if(c[i].a<0)p1[i]++;}
			}
		}
		for(int i=1;i<=n;i++){
			if(p1[i]>0) ans++;
		}
		cout<<sum<<" "<<ans+1<<"\n";
	}
    return 0;
}
